package org.xcorpio.thread;

//ThreadTest.java 源码
class MyThread  extends Thread{  
 private int ticket=10;  
 public void run(){
     for(int i=0;i<10;i++){ 
         if(this.ticket>0){
        	// System.out.println("this对象为："+this);
             System.out.println(Thread.currentThread().getName()+" 卖票：ticket"+this.ticket);
             ticket = ticket-1;
         }
     }
 } 
};

public class ThreadTest {  
 public static void main(String[] args) {  
     // 启动3个线程t1,t2,t3；每个线程各卖10张票！
	 MyThread  t1=new MyThread ();
	 MyThread  t2=new MyThread ();
	 MyThread  t3=new MyThread ();
	 //System.out.println("t1对象为："+t1+"-------t2对象为："+t2+"----t3对象为："+t3);
     t1.start();
     t2.start();
     t3.start();
 }  
}